function like = LogLikelihood_alt_bias2(param)

%% GLOBAL

global Y T1 T2 SM SR Draws M Xc ll


%% PARAM def 
cm = param(1);
cr = param(2);
phir = param(3);
c1 = param(4);
phi1 = param(5);
sigem = param(6);
siger = param(7);
sigtheta = param(8);
c2 = param(9);
phi2 = param(10);
cy = param(11);
phim = param(12);
gamma1 = param(13);
gamma2 = param(14);
by = param(15);
b1 = param(16);
b2 = param(17);
cgpa = param(18);
phigpa = param(19);
sigegpa = param(20);
sige1 = 1;
sige2 = 1;
sigy = 1;

%%

theta = Draws*sigtheta;

Lsm = normalpdf(repmat(SM,1,M)-cm-phim*theta,0,sigem);
Lsr = normalpdf(repmat(SR,1,M)-cr-phir*theta,0,siger);
Lt1 = (normcdf(c1+phi1*theta+b1*repmat(Xc,1,M), 0, sige1).^repmat(T1,1,M)).*((1-normcdf(c1+phi1*theta+b1*repmat(Xc,1,M), 0,sige1)).^(1-repmat(T1,1,M)));
Lt2 = (normcdf(c2+phi2*theta+b2*repmat(Xc,1,M), 0, sige2).^repmat(T2,1,M)).*((1-normcdf(c2+phi2*theta+b2*repmat(Xc,1,M), 0,sige2)).^(1-repmat(T2,1,M)));
Lgpa = normalpdf(repmat(Xc,1,M)-cgpa-phigpa*theta,0,sigegpa);

%% Bias

yind = normcdf(cy+theta+by*repmat(Xc,1,M));
yind = yind+0;
b1 = repmat(T1,1,M);
b2 = repmat(T2,1,M);


Ly = (normcdf(cy+theta+gamma1*b1+gamma2*b2+by*repmat(Xc,1,M), 0, sigy).^repmat(Y,1,M)).*((1-normcdf(cy+theta+gamma1*b1+gamma2*b2+by*repmat(Xc,1,M), 0, sigy)).^(1-repmat(Y,1,M)));

%% Individual Likelihood Contribution
Lm=((((Lsm.*Lsr).*Lt1).*Lt2).*Ly).*Lgpa;


%% log likelihood
ll = (log(mean(Lm,2)));
like = -sum(log(mean(Lm,2)));